﻿@{
    ViewData["Title"] = "DeviceEdit";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@model SecurityDevice
<div class="page-container">
    <form class="form form-horizontal" id="form-device-edit">
        <input type="hidden" class="input-text" value="@Model.Id" id="id" name="id" required="required">
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>设备序列号：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="@Model.SerialNumber" id="" name="name" required="required" readonly="readonly">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>设备分组：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <span class="select-box">
                    <select name="categoryId" class="select">
                        @foreach (var item in ViewBag.category)
                        {
                            if (item.Id == Model.SecurityCategoryId)
                            {
                                <option value="@item.Id" selected="selected">@item.Name</option>
                            }
                            else
                            {
                                <option value="@item.Id">@item.Name</option>
                            }
                        }
                    </select>
                </span>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>设备名称：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="@Model.Name" placeholder="请输入设备名称" id="" name="name" required="required">
            </div>
        </div>
    </form>
</div>

<div class="row cl">
    <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
        <button onClick="device_save_submit();" class="btn btn-primary radius" type="submit"><i class="Hui-iconfont">&#xe632;</i> 保存</button>
        <button onClick="layer_close();" class="btn btn-default radius" type="button">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
    </div>
</div>
<script type="text/javascript">
    function device_save_submit() {
        var data = $("#form-device-edit").serialize();
        $.ajax({
            type: "POST",
            url: "/devicecategory/deviceEditProcess",
            dataType: "json",
            data: data,
            success: function (msg) {
                if (msg.succeed) {
                    layer.msg('操作成功!', { icon: 1, time: 1500 }, function () {
                        window.parent.location.reload();
                        parent.layer.close(index);
                    });
                } else {
                    layer.msg('操作失败!', { icon: 1, time: 1500 });
                };
            },
            error: function (msg) {
                layer.msg('操作失败!', { icon: 1, time: 1500 });

            }
        });
    }
</script>

